<script setup>
import { ref } from 'vue'
import { useMemberStore } from '@/stores'

const memberStore = useMemberStore()

// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()

const goFunctionClick = (val) => {
  if (val == 'device') {
    // 跳转到我的设备页面
    uni.navigateTo({ url: '/pagesMember/device/device' })
  } else {
    // 跳转到修改密码页面
    uni.navigateTo({ url: '/pagesMember/changePassword/changePassword' })
  }
}
</script>

<template>
  <scroll-view class="viewport" scroll-y enable-back-to-top>
    <view class="content" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
      <view class="overview">
        <navigator url="/pages/login/login" hover-class="none">
          <image class="avatar" mode="aspectFill" :src="memberStore.userInfo?.avatar"></image>
        </navigator>
        <view class="meta">
          <navigator url="/pages/login/login" hover-class="none" class="nickname">
            {{ memberStore.userInfo?.userName }}
          </navigator>
        </view>
        <navigator class="settings" url="/pagesMember/settings/settings" hover-class="none">
          <image src="../../static/images/forward.png" mode="scaleToFill" />
        </navigator>
      </view>
      <!-- leftTitle:标题  icon：左边图标 @click：点击事件  -->
      <cc-wxMenuBtn
        leftTitle="我的设备"
        icon="../../static/images/device.png"
        @click="goFunctionClick('device')"
      ></cc-wxMenuBtn>
      <cc-wxMenuBtn
        leftTitle="修改密码"
        icon="../../static/images/password.png"
        @click="goFunctionClick('password')"
      ></cc-wxMenuBtn>
    </view>
  </scroll-view>
</template>

<style lang="scss">
page {
  height: 100%;
  overflow: hidden;
  background-color: #fff;
}

.viewport {
  height: 100%;
  background-repeat: no-repeat;
  background-size: 100% auto;
}

.content {
  position: relative;
  .overview {
    display: flex;
    height: 300rpx;
    padding: 100rpx 50rpx;
  }
  .avatar {
    width: 200rpx;
    height: 120rpx;
    border-radius: 10rpx;
    background-color: #eee;
  }
  .gray {
    filter: grayscale(100%);
  }

  .meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    line-height: 30rpx;
    padding: 16rpx 0;
    margin-left: 20rpx;
  }

  .nickname {
    max-width: 350rpx;
    font-size: 30rpx;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .extra {
    display: flex;
    font-size: 20rpx;
  }

  .tips {
    font-size: 22rpx;
  }

  .update {
    padding: 3rpx 10rpx 1rpx;
    color: rgba(255, 255, 255, 0.8);
    border: 1rpx solid rgba(255, 255, 255, 0.8);
    margin-right: 10rpx;
    border-radius: 30rpx;
  }

  .settings {
    position: absolute;
    top: 220rpx;
    right: 36rpx;
    image {
      width: 35rpx;
      height: 35rpx;
    }
  }
}
</style>
